<html> 
<head> 
<title> </title>
<style> 
px {font-family: "Lucida Console", Monaco }
p { font-size:100%; line-height:1.1em; }
body {xfont-style: sans-serif}
body {
color:#333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; line-height:1.3em; }
a:visited { color:#666; }
h1,h2,h3,h4,h5,h6 { color:#333; font-family:georgia, verdana, sans-serif; }
h1 { font-size:150%; page-break-before:auto;background-color: #aaaaff}
h2 { font-size:143%;color:teal; }
h3 { font-size:134%;color:blue; }
h4 { font-size:120%;color:gray; }
img { max-width: 55em}
p{ padding: 0;margin:0; }
p{ padding-right:1.4em; }
p{ padding-bottom:0.1em; }
p{ padding-top:1em; }
p{ whitespace: pre-wrap; }
h5,h6 { font-size:100% }
a.nav,a:link.nav, a:visited.nav { background-color:#FFF; color:#000; }
XXtable { border:double #000; border-collapse:collapse; }
XXtable { border-collapse:collapse; }
XXtd { border:thin solid #888; }
XXtd { border:none; }
li { margin-bottom:0.5em; }
blockquote { display:block; font-size:100%; line-height:1.1em; margin:0 0 0.5em; padding:0 2.5em; }
pre { background-color:#DDD; font-size:100%; overflow:auto; padding:1em; }
a,li span { color:#000; }
a:hover, a.nav:hover, a:hover math { background-color:#000; color:#FFF; }
#Container { margin:0 10px; text-align:center; background-color: #BBB}
#Content { border-top:none; margin:auto; padding:0.3em; text-align:left; width:100%; max-width:55em; background:#FFF}
span.webName { font-size:.5em; }
textarea#content { font-size: 1em; line-height: 1.125; }
h1#pageName { line-height:1em; margin:0.2em 0 0.2em 0; padding:0; }
.property { color:#666; font-size:100%; }
a.existingWikiWord[title]{ //border: 1px dashed #BBB; }
.byline { color:#666; font-size:1.0em; font-style:italic; margin-bottom:1em; padding-top:1px; } 
</style> 
</head>
<BODY bgcolor=#F0F0F0 text=#000000 link=#0000ff vlink=#C000C0 alink=#ff0000><A NAME=top></A>
<h5><a href="https://github.com/urbanjost/M_strings">[UP]</a></h5>
<div id="Container">
<div id="Content">
<CENTER>
<H1><HR><I>Manual Reference Pages &nbsp;-&nbsp;</I><NOBR>split (3m_strings)</NOBR><HR></H1>
</CENTER>
<A name=0>

     <H3>NAME</H3>

</A>
<BLOCKQUOTE>
<B>split</B>(3f) - [M_strings:TOKENS] parse string into an array using
specified delimiters
(LICENSE:PD)
<P>
</BLOCKQUOTE>
<A name=contents></A><H3>CONTENTS</H3></A>
<BLOCKQUOTE>
<A HREF=#1>Synopsis</A><BR>
<A HREF=#2>Description</A><BR>
<A HREF=#3>Options</A><BR>
<A HREF=#4>Examples</A><BR>
<A HREF=#5>Author</A><BR>
<A HREF=#6>License</A><BR>
</BLOCKQUOTE>
<A name=7>

     <H3>SYNOPSIS</H3>

</A>
<BLOCKQUOTE>
subroutine <B>split</B>(input_line,array,delimiters,order,nulls)
<P>
<PRE>
    character(len=*),intent(in)              :: input_line
    character(len=:),allocatable,intent(out) :: array(:)
    character(len=*),optional,intent(in)     :: delimiters
    character(len=*),optional,intent(in)     :: order
    character(len=*),optional,intent(in)     :: nulls
<P>
</PRE>
</BLOCKQUOTE>
<A name=2>

     <H3>DESCRIPTION</H3>

</A>
<BLOCKQUOTE>
<B>SPLIT</B>(3f) parses a string using specified delimiter characters and
store tokens into an allocatable array
</BLOCKQUOTE>
<A name=3>

     <H3>OPTIONS</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD colspan=2>
<B>INPUT_LINE</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
Input string to tokenize
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>ARRAY</B> </TD><TD valign=bottom>
Output array of tokens
</TD></TR>
<TR valign=top><TD colspan=2>
<B>DELIMITERS</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
List of delimiter characters.
The default delimiters are the "whitespace" characters
(space, tab,new line, vertical tab, formfeed, carriage
return, and null). You may specify an alternate set of
delimiter characters.
<P>
Multi-character delimiters are not supported (Each
character in the DELIMITERS list is considered to be
a delimiter).
<P>
Quoting of delimiter characters is not supported.
</TD></TR>
<TR valign=top><TD colspan=2>
<B>ORDER SEQUENTIAL|REVERSE|RIGHT</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
Order of output array.
By default ARRAY contains the tokens having parsed
the INPUT_LINE from left to right. If ORDER=&#146;RIGHT&#146;
or ORDER=&#146;REVERSE&#146; the parsing goes from right to left.
(This can be accomplished with array syntax in modern
Fortran, but was more useful pre-fortran90).
</TD></TR>
<TR valign=top><TD colspan=2>
<B>NULLS=IGNORE|RETURN|IGNOREEND</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
Treatment of null fields.
By default adjacent delimiters in the input string
do not create an empty string in the output array. if
NULLS=&#146;return&#146; adjacent delimiters create an empty element
in the output ARRAY. If NULLS=&#146;ignoreend&#146; then only
trailing delimiters at the right of the string are ignored.
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<A name=4>

     <H3>EXAMPLES</H3>

</A>
<BLOCKQUOTE>
Sample program:
<P>
<PRE>
   program demo_split
   use M_strings, only: split
   implicit none
   integer :: i
   character(len=*),parameter     :: line=&
   &#146;  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|333 a B cc    &#146;
   character(len=:),allocatable :: array(:) ! output array of tokens
      write(*,*)&#146;INPUT LINE:[&#146;//line//&#146;]&#146;
      write(*,&#146;(70("="))&#146;)
      write(*,*)&#146;typical call:&#146;
      call split(line,array)
      write(*,&#146;(i0," ==&gt; ",a)&#146;)(i,trim(array(i)),i=1,size(array))
      write(*,*)&#146;SIZE:&#146;,size(array)
      write(*,&#146;(70("-"))&#146;)
      write(*,*)&#146;custom list of delimiters (colon and vertical line):&#146;
      call split(line,array,delimiters=&#146;:|&#146;,&
      & order=&#146;sequential&#146;,nulls=&#146;ignore&#146;)
      write(*,&#146;(i0," ==&gt; ",a)&#146;)(i,trim(array(i)),i=1,size(array))
      write(*,*)&#146;SIZE:&#146;,size(array)
      write(*,&#146;(70("-"))&#146;)
      write(*,*) &#146;custom list of delimiters, &
      &reverse array order and count null fields:&#146;
      call split(line,array,delimiters=&#146;:|&#146;,&
      &order=&#146;reverse&#146;,nulls=&#146;return&#146;)
      write(*,&#146;(i0," ==&gt; ",a)&#146;)(i,trim(array(i)),i=1,size(array))
      write(*,*)&#146;SIZE:&#146;,size(array)
      write(*,&#146;(70("-"))&#146;)
      write(*,*)&#146;INPUT LINE:[&#146;//line//&#146;]&#146;
      write(*,*) &#146;default delimiters and reverse array order &
      &and return null fields:&#146;
      call split(line,array,delimiters=&#146;&#146;,order=&#146;reverse&#146;,nulls=&#146;return&#146;)
      write(*,&#146;(i0," ==&gt; ",a)&#146;)(i,trim(array(i)),i=1,size(array))
      write(*,*)&#146;SIZE:&#146;,size(array)
   end program demo_split
<P>
</PRE>
Output
<P>
<PRE>
  &gt;INPUT LINE:[  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|
  333 a B cc    ]
  &gt;=================================================================
  &gt; typical call:
  &gt;1 ==&gt; aBcdef
  &gt;2 ==&gt; ghijklmnop
  &gt;3 ==&gt; qrstuvwxyz
  &gt;4 ==&gt; 1:|:2
  &gt;5 ==&gt; 333|333
  &gt;6 ==&gt; a
  &gt;7 ==&gt; B
  &gt;8 ==&gt; cc
  &gt; SIZE:           8
  &gt;----------------------------------------------------------------
  &gt; custom list of delimiters (colon and vertical line):
  &gt;1 ==&gt;   aBcdef   ghijklmnop qrstuvwxyz  1
  &gt;2 ==&gt; 2     333
  &gt;3 ==&gt; 333 a B cc
  &gt; SIZE:           3
  &gt;----------------------------------------------------------------
  &gt; custom list of delimiters, reverse array order and
  return null fields:
  &gt;1 ==&gt; 333 a B cc
  &gt;2 ==&gt; 2     333
  &gt;3 ==&gt;
  &gt;4 ==&gt;
  &gt;5 ==&gt;   aBcdef   ghijklmnop qrstuvwxyz  1
  &gt; SIZE:           5
  &gt;----------------------------------------------------------------
  &gt; INPUT LINE:[  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|
  333 a B cc    ]
  &gt; default delimiters and reverse array order and count null fields:
  &gt;1 ==&gt;
  &gt;2 ==&gt;
  &gt;3 ==&gt;
  &gt;4 ==&gt; cc
  &gt;5 ==&gt; B
  &gt;6 ==&gt; a
  &gt;7 ==&gt; 333|333
  &gt;8 ==&gt;
  &gt;9 ==&gt;
  &gt;10 ==&gt;
  &gt;11 ==&gt;
  &gt;12 ==&gt; 1:|:2
  &gt;13 ==&gt;
  &gt;14 ==&gt; qrstuvwxyz
  &gt;15 ==&gt; ghijklmnop
  &gt;16 ==&gt;
  &gt;17 ==&gt;
  &gt;18 ==&gt; aBcdef
  &gt;19 ==&gt;
  &gt;20 ==&gt;
  &gt; SIZE:          20
<P>
</PRE>
</BLOCKQUOTE>
<A name=5>

     <H3>AUTHOR</H3>

</A>
<BLOCKQUOTE>
John S. Urban
</BLOCKQUOTE>
<A name=6>

     <H3>LICENSE</H3>

</A>
<BLOCKQUOTE>
Public Domain
</BLOCKQUOTE>
<P><HR>
<TABLE width=100%><TR> <TD width=33%><I>Nemo Release 3.1</I></TD> <TD width=33% align=center>split (3m_strings)</TD> <TD align=right width=33%><I>April 30, 2022</I></TD> </TR></TABLE><FONT SIZE=-1>Generated by <A HREF="http://www.squarebox.co.uk/download/manServer.shtml">manServer 1.08</A> from 9b5e9c11-f122-4083-8cab-cf40229c739f using man macros.</FONT>
<br><br><center><img src="images/split.gif"></center>
</div>
</div>
</body>
</HTML>
